package org.example.tree;

import java.util.ArrayList;
import java.util.List;

/**
 * @author liyishan
 * @date 2024/7/4 10:03
 * @apiNote
 */

public class Test00897IncreasingBST {
    public TreeNode increasingBST(TreeNode root) {
        List<Integer> res = new ArrayList<>();
        inorder(root,res);
        TreeNode dummyNode = new TreeNode(-1);
        TreeNode currNode = dummyNode;
        for(int value : res){
            currNode.right = new TreeNode(value);
            currNode = currNode.right;
        }
        return dummyNode.right;
    }

    public void inorder(TreeNode node, List<Integer> res){
        if(node == null){
            return;
        }
        inorder(node.left,res);
        res.add(node.val);
        inorder(node.right,res);
    }


}
